﻿package org.dm.3d.Actions.cameras 
{
	import org.dm.3d.cameras.CameraBase;
	import org.dm.3d.geom.Num3D;
	/**
	 * ...
	 * @author Scott
	 */
	public class RanTurn extends CAction
	{
		
		public function RanTurn() 
		{
			this.isUsed = true;
		}
		public override function update(items:CameraBase):void 
		{
			var angSpeed:Num3D = items.angleSpeed;
			var angle:Num3D = items.angle;
			items.damping = .998;
			if (Math.abs(angSpeed.x) < .0001)
			{
				if (angle.x > .3) 
					angSpeed.x = -.005 - .005 * Math.random();
				else if (angle.x < -.3)
					angSpeed.x = .005 + .005 * Math.random();
				else
					angSpeed.x = (Math.random()>.5?.005:-.005) * (1+Math.random());
			}
			if (Math.abs(angSpeed.y) < .00005)
			{
				if (angle.y > .2) 
					angSpeed.y = -.005 - .005 * Math.random();
				else if (angle.y < -.2)
					angSpeed.y = .005 + .005 * Math.random();
				else
					angSpeed.y = (Math.random()>.5?.005:-.005) * (1+Math.random());
			}
		}	
	}
	
}